<template>
    <view @click="zanIt(id)" class="cu-btn round bg-white" :class="love?' c02':''">
    	<text class="fa fa-heart" v-if="love"></text>
    	<text class="fa fa-heart-o" v-if="!love"></text>
    	<text class="padl1" v-if="num == 0">{{love?'已赞':placeholder}}</text>
    	<text class="padl1" v-if="num > 0">{{num}}</text>
    	<ripple></ripple>
    </view>
</template>

<script>
	import Zan from '../../assets/js/zan.js'
    export default {
        name: "stext",
        props: {
			itemId: "",
			src: "",
			placeholder: {
				type:String,
				default:"点赞"
			}
        },
        data() {
            return {
				zan:undefined,
				love:false,
				num:0
            }
        },
        methods: {
           zanIt(id){
			   this.love = this.zan.zan(id)
		   },
		   checkIt(){
			   this.love = this.zan.check(this.itemId)
		   }
        },
        mounted() {
            this.zan = Zan
			
			this.zan.setSrc(this.src).init(this.checkIt)
        },
    }
</script>

<style>
    .cu-form-group .title {
    	min-width: calc(4em + 15px);
    }
</style>
